package com.xcity.robot.net.util;

import java.util.concurrent.atomic.AtomicInteger;

import com.xcity.robot.net.Session;

public interface SessionUtils {

	String SESSION = ".session";
//	@Deprecated
//	String HANDSHAKE_LISTENER = ".handshakeListener";
	String POMELO_HANDSHAKE_LISTENER = ".pomelohandshakelistener";
	String REQUEST_SERIAL = ".serial";
	String POMELO_DICT = ".dict";
	String RECEIVE_HEARTBEAT_NUM = ".heartbeat";
	String REQUEST_MAP = ".requestMap";
	
	public static int nextSerial(Session session) {
		AtomicInteger gen = (AtomicInteger) session.getAttribute(REQUEST_SERIAL);
		if (gen == null) {
			gen = new AtomicInteger();
			session.setAttribute(REQUEST_SERIAL, gen);
		}
		return gen.incrementAndGet();
	}
	
}
